package com.cn.wanxi.util.utils;

import com.cn.wanxi.util.model.AboutContentModel;
import com.cn.wanxi.util.model.AboutNavModel;
import com.cn.wanxi.util.model.AnimationModel;

import java.util.ArrayList;
import java.util.List;

public class AboutNavUtil {
    FileUtile fileUtile =new FileUtile();
    public List<AboutNavModel> readNavfile(){
        List<AboutNavModel> aboutNavModels = new ArrayList<>();
//        调用读取文档
        String context = fileUtile.readFileToString("AboutNavFile.txt");
        String[] navs = context.split(";");
        for (int i=0;i<navs.length;i++){
            String item = navs[i];
            String[] info = item.split(",");
            AboutNavModel aboutNavModel = new AboutNavModel(info[0].trim(),info[1].trim(),info[2].trim());
            aboutNavModels.add(aboutNavModel);
        }
        return aboutNavModels;
    }

    public List<AboutContentModel> readAboutContent(){
        List<AboutContentModel> aboutContentList =new ArrayList<>();

        String context = fileUtile.readFileToString("AboutContentFiel.txt");
        String[] contents = context.split(";");
        for(int i=0;i<contents.length;i++){
            String item = contents[i];
            String[] info = item.split(",");
            AboutContentModel aboutContentModel =new AboutContentModel(info[0].trim(),info[1].trim());
            aboutContentList.add(aboutContentModel);
        }
        return aboutContentList;
    }

    public List<AnimationModel> readAnimationModel(){
        List<AnimationModel> animationList =new ArrayList<>();
        String animationListText =fileUtile.readFileToString("AnimationFile.txt");
        String[] items = animationListText.split(";");
        for (int i = 0;i<items.length;i++){
            String item = items[i];
            String[] info = item.split(",");
            AnimationModel animationModel =new AnimationModel(info[0].trim(),info[1].trim(),info[2].trim());
            animationList.add(animationModel);
        }
        return animationList;
    }
}
